package com.xpgk.mvc.productSet;

import java.util.Date;

import com.jfinal.core.Controller;
import com.jfinal.kit.StrKit;
import com.jfinal.log.Log;
import com.xpgk.mvc.base.BaseValidator;
import com.xpgk.mvc.user.User;
import com.xpgk.tools.ToolDateTime;
import com.xpgk.tools.ToolRandoms;

@SuppressWarnings({ "unused" })
public class ProductValidator extends BaseValidator {

	private static final Log log = Log.getLog(ProductValidator.class);


	protected void validate(Controller controller) {
		String actionKey = getActionKey();
		if (actionKey.equals("/productSet/addProduct")) {

			 vali();

		} else if (actionKey.equals("/productSet/upProduct")) {

			// 验证参数
			 vali();
			 
		}
	}

	protected void vali() {
		/*if(StrKit.isBlank(controller.getPara("product.useIds")) || "-1".equals(controller.getPara("product.useIds"))){
			addError("msg", "请选择产品用途!");
		}*/
		//validateString("product.useIds", 32, 32, "msg", "请选择产品用途!");
		//validateInteger("product.proCapacity", "msg", "请填写正确的产品容量,如:20 !");
		//validateString("product.proUnits", 1, 50, "msg", "请填写产品单位!");
		validateString("product.proSpecification", 1, 50, "msg", "请填写产品规格!");
		validateString("product.name", 1, 50, "msg", "请填写产品名称!");
		validateString("product.proBh", 1, 50, "msg", "请填写产品编号!");
		
	}

	protected void handleError(Controller controller) {
		controller.renderJson();
	}

}
